import request from '@/z/callback/request'

export async function login(data) {
  let loginpar = await request('/Login', data)
  if (loginpar[0].par != 'succeed') {
    return loginpar[0]
  }
  return getUSearch()
}
export async function getUSearch() {
  let GetSession = await request('/GetSession')
  if (GetSession[0].utype == 99) {
    return {}
  }
  let USearch = await request('/USearch', {
    uUser: GetSession[0].uUser,
  })
  return USearch.length == 1 ? USearch[0] : {}
}
export function getUserInfo() {
  return request('/GetSession')
}

export function logout() {
  return request('/logout')
}

export function register(data) {
  return request({
    url: '/register',
    method: 'post',
    data,
  })
}
